#include <Volume.h>
#include <iostream>
#include <sstream>

#define COEFFICIENTPEROZ 48
#define COEFFICIENTPERTBS 16
#define COEFFICIENTPERTSP 1

VolumeUnit::VolumeUnit(const int coeffientOfBaseUnit): Unit(coeffientOfBaseUnit,TYPE_VOLUME)
{   
}

const VolumeUnit& VolumeUnit::oz()
{
  static VolumeUnit unit(COEFFICIENTPEROZ);
  return unit;
}

const VolumeUnit& VolumeUnit::tbs()
{
  static VolumeUnit unit(COEFFICIENTPERTBS);
  return unit;
}

const VolumeUnit& VolumeUnit::tsp()
{
  static VolumeUnit unit(COEFFICIENTPERTSP);
  return unit;
}
const std::string VolumeUnit::showUnitStepString(int amount)
{
    ostringstream os;
    int baseUnitValue = this->getBaseVlaue(amount);
    int ozValue = 0;
    int tbsValue = 0; 

    if(baseUnitValue)
    {
       if(ozValue = baseUnitValue / COEFFICIENTPEROZ) 
       {
          baseUnitValue = baseUnitValue % COEFFICIENTPEROZ;
          if(ozValue)
            os << ozValue << " OZ ";
          else
            os << ozValue << " OZ";
       }
       if(tbsValue = baseUnitValue / COEFFICIENTPERTBS) 
       {
          baseUnitValue = baseUnitValue % COEFFICIENTPERTBS;
          if(baseUnitValue)
            os << tbsValue << " TBS ";
          else
            os << tbsValue << " TBS";
       }
       if(baseUnitValue) 
       {
          os << baseUnitValue << " TSP";
       }
    }
    else
    {
        os << baseUnitValue << " TSP";
    }  
}
const std::string VoumeUnit::showBaseUnitString(int amount)
{
    ostringstream os;
    int baseUnitValue = this->getBaseVlaue(amount);
    os << baseUnitValue << " TSP";
    cout<< os.str() << "!" <<endl;
    return os.str();
}


